package com.atguigu.sort;

import com.atguigu.utils.ArrayGenerator;
import com.atguigu.utils.SortingHelper;
import org.junit.Test;

import java.net.SocketTimeoutException;
import java.util.*;

public class QuickSortTest {

    @Test
    public void testQuickSort(){
        Integer[]arr={89,78,34,90,12,34,13,22};
        QuickSort.Sort(arr);
        System.out.println(Arrays.toString(arr));
    }
    @Test
    public void testOrderArray(){
        int n=10;
        Integer[] array = ArrayGenerator.generateRandomArray(n,n);
        System.out.println(Arrays.toString(array));
        QuickSort.Sort(array);
        System.out.println(Arrays.toString(array));
    }
    @Test
    public void testEqualArray(){
        int n=1000000;
        Integer[] array = ArrayGenerator.generateRandomArray(n,1);
        Integer[] array1 = Arrays.copyOf(array,array.length);
        Integer[] array2 = Arrays.copyOf(array,array.length);
        SortingHelper.sortTest("MergeSort",array);
        SortingHelper.sortTest("QuickSort",array1);
        SortingHelper.sortTest("QuickSort3Ways",array2);
    }
    @Test
    public void testParition4(){
        int n=100000;
        Integer[] array = ArrayGenerator.generateRandomArray(n,n);
        SortingHelper.sortTest("QuickSort",array);
        array=ArrayGenerator.generateOrderArray(n);
        SortingHelper.sortTest("QuickSort",array);

    }
}
